package com.pxmeta.statistics.service;

import com.pxmeta.statistics.bo.UvStatisticBO;
import com.pxmeta.statistics.bo.UvStatisticResult;
import com.pxmeta.statistics.dao.UvStatisticDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author shoushen.luan
 * @since 2022-10-20
 */
@Service
public class StatisticService {
    @Autowired
    private UvStatisticDAO uvStatisticDAO;

    public void addRecord(String serverHost, Date statDate, Long accessCount) {
        UvStatisticBO uvStatisticsBO = new UvStatisticBO();
        uvStatisticsBO.setAccessCount(accessCount);
        uvStatisticsBO.setServerHost(serverHost);
        uvStatisticsBO.setStatDate(statDate);
        uvStatisticDAO.saveOrUpdate(uvStatisticsBO);
    }

    public List<UvStatisticResult> getStatList() {
        return uvStatisticDAO.getList();
    }
}
